Skip to main content
PVAC-HFHE supports fully homomorphic arithmetic on encrypted data. This guide covers all arithmetic operations with real code examples.

Overview

All arithmetic operations are in include/pvac/ops/arithmetic.hpp:
Addition and subtraction do not increase circuit depth and are extremely fast (0.012ms). Multiplication increases depth by 1.

Addition

Add two ciphertexts with ct_add:

Implementation

From include/pvac/ops/arithmetic.hpp:165-188:

Properties

From examples/basic_usage.cpp:72-73:
Commutative and associative:

Performance

From benchmark data:
  • Time: 0.012 ms (mean)
  • 10-87x faster than RLWE schemes (BFV: 0.124ms, CKKS: 1.05ms)
Addition is essentially free in PVAC-HFHE—it’s just graph concatenation with no cryptographic operations.

Subtraction

Subtract ciphertexts with ct_sub:

Implementation

From include/pvac/ops/arithmetic.hpp:190-192:
Subtraction is implemented as addition with negation:

Properties

From examples/basic_usage.cpp:81-82:
Difference of squares:

Multiplication

Multiply ciphertexts with ct_mul:

Function signature

From include/pvac/ops/arithmetic.hpp:194:
Parameters:
  • pk: Public key
  • A, B: Input ciphertexts
  • S: Number of edges per product layer (default 8)
The parameter S controls the trade-off between ciphertext size and noise. Larger S means more edges but better noise distribution.

Properties

From examples/basic_usage.cpp:75-79:
Commutative and associative:
Distributive property:

Performance

From benchmark data:
  • Time: 2.47 ms (mean)
  • 2.9-14.3x faster than RLWE schemes:
    • BFV shallow: 7.23ms (2.9x slower)
    • BFV leveled: 18.28ms (7.4x slower)
    • CKKS: 35.23ms (14.3x slower)

Squaring

Square a ciphertext efficiently with ct_square:

Why use ct_square?

Squaring is more efficient than ct_mul(pk, a, a) because it exploits symmetry:
  • ct_mul(a, a): Creates L_a × L_a product layers
  • ct_square(a): Creates L_a × (L_a + 1) / 2 layers (triangular)
From include/pvac/ops/arithmetic.hpp:227-255:

Constant operations

Perform operations with plaintext constants:

Add constant

Multiply constant

Subtract constant

From include/pvac/ops/arithmetic.hpp:261-291:
Constant operations are extremely fast because they don’t require homomorphic operations—just scalar arithmetic on the ciphertext structure.

Example: Polynomial evaluation

Evaluate f(x) = x³ + 2x² + 3x + 4 at x = 5: From examples/basic_usage.cpp:137-148:

Example: Binomial expansion

Verify (a + b)² = a² + 2ab + b²: From examples/basic_usage.cpp:108-118:

Example: Fibonacci sequence

Compute fib(10) = 55: From examples/basic_usage.cpp:178-186:
The Fibonacci computation uses only additions, so it stays at depth 0 and completes very quickly.

Next steps

Depth management

Understand circuit depth and noise growth

Performance tuning

Optimize arithmetic operations